public class YaHui {
    public static void main(String[] args) {
        Yanghui(5);
    }

    public static void Yanghui(int n) {
      int[][] arr = new int[n][n];
        for (int i = 0; i < n; i++) {
            arr[i][0] = 1;
            arr[i][i] = 1;
            if (i >= 2) {
                for (int j =1; j < i; j++) {
                    arr[i][j] = arr[i - 1][j] + arr[i - 1][j - 1];
                    //计算杨辉三角
                }
            }
        }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j <= i; j++) {
                    System.out.print(arr[i][j] + " ");
                } System.out.println();
            }
        /*for (int i = n - 1; i >= 0; i--) {
            for (int a = 0; a < n - i; a++) {
                System.out.print(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }*/
    }
}

